﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Business.Base.DB.Query
{
    public class BaseQuery
    {
        private int pageSize=1;
        private int pageNum=1;
        private String orderBy = "Id";
        private String orderType="desc";
        private bool addOrder = true;
 

        public virtual int PageSize { get => pageSize; set => pageSize = value; }
        public virtual int PageNum { get => pageNum; set => pageNum = value; }
        public virtual string OrderBy { get => orderBy; set => orderBy = value; }
        public virtual string OrderType { get => orderType; set => orderType = value; }




        public virtual string ToSQLConditionString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(this.ToSQLConditionWithOutSort());
            if (addOrder && this.OrderBy != null)
            {
                sb.Append(" order by " + this.OrderBy);
                sb.Append(" " + this.OrderType);
            }
            return sb.ToString();
        }

        public virtual string ToSQLConditionWithOutSort()
        { return ""; }


    }
}
